/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author melvinrafaelvegavega
 */
import java.io.*;
import java.util.*;
public class ejecucion {
public static void main(String[] args)throws IOException
{
    try{
     String[] command = {"sh","-c","java -classpath /Users/melvinrafaelvegavega/Desktop/consola"};
     Runtime process = Runtime.getRuntime();
     Process proc=process.exec("/bin/bash");
     /*int exitVal = proc.waitFor();
     System.out.println("Process exitValue: " + exitVal);*/
     //BufferedReader brStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
     //BufferedReader brStdErr = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
     //brStdOut.close();
     //brStdErr.close(); 
     BufferedOutputStream out = new BufferedOutputStream(proc.getOutputStream());
     out.write("cd /Users/melvinrafaelvegavega/Desktop/;javac algoritmo.java;chmod 777 algoritmo.class;java algoritmo;".getBytes());
     out.flush();
     out.close();
     proc.waitFor();
    }
    catch(Exception e) {
        System.out.println(e.toString());
        e.printStackTrace();
     }

}
}
